package com.car.carmgr.controller;

import com.car.carmgr.bean.BaseStat;
import com.car.carmgr.service.CustomerService;
import com.car.carmgr.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
@RequestMapping("stat")
public class StatisticsPageController {

    @Autowired
    private CustomerService customerService;

    @RequestMapping("customerLocation")
    public String customerLocationMgr(){
        return "business/statistics/customerLocationStat";
    }

    @RequestMapping("mouthSole")
    public String mouthSoleMgr(){
        return "business/statistics/mouthSoleStat";
    }

    @RequestMapping("yearSole")
    public String yearSoleMgr(){
        return "business/statistics/yearSoleStat";
    }

    @RequestMapping("customerStatJson")
    @ResponseBody
    public AjaxResult customerStatJson(){
        List<BaseStat> countByAddress = customerService.getCountByAddress();
        return AjaxResult.ok(countByAddress);
    }
}
